package com.reactim.message.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 消息读取状态实体类
 */
@Data
@Document(collection = "message_read_status")
@CompoundIndexes({
    @CompoundIndex(name = "message_user_idx", def = "{'messageId': 1, 'readStatus.userId': 1}", unique = true)
})
public class MessageReadStatus {
    
    @Id
    private String id;
    
    @Indexed(unique = true)
    private String messageId;           // 消息ID
    
    private List<ReadInfo> readStatus;  // 读取状态列表
    
    private LocalDateTime createdAt;    // 创建时间
    
    /**
     * 读取信息
     */
    @Data
    public static class ReadInfo {
        private Long userId;            // 用户ID
        private LocalDateTime readAt;   // 读取时间
    }
}